package com.heima.search.controller;

import com.heima.apis.search.UserSearchControllerApi;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.UserSearchDto;
import com.heima.search.service.UserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/user_search")
public class UserSearchController implements UserSearchControllerApi {

    @Autowired
    UserSearchService userSearchService;

    /**
     * 保存用户搜索关键词
     * @param dto
     * @return
     * @throws Exception
     */
    @GetMapping("/save")
    @Override
    public ResponseResult saveSearch(@RequestBody UserSearchDto dto) throws Exception {

        return userSearchService.saveSearch(dto);
    }

    /**
     * 删除用户搜索词
     * @param dto
     * @return
     * @throws Exception
     */
    @PostMapping("/delSearch")
    @Override
    public ResponseResult delSearch(@RequestBody UserSearchDto dto) throws Exception {
        return userSearchService.delSearch(dto);
    }
}
